home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Settings.cs624 < prev    next >
Text File  |  2008-01-25  |  31KB  |  569 lines

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Specialized;
  4. using System.IO;
  5. using System.Reflection;
  6. using System.Xml;
  7. using System.Web;
  8. using Microsoft.Win32;
  9. using GBPVR.Public;
  10.  
  11. using IPNumbers;
  12.  
  13. namespace gbweb
  14. {
  15.     /// <summary>
  16.     /// Summary description for Settings.
  17.     /// </summary>
  18.     public class Settings
  19.     {
  20.         public bool autoShowSearch = false;
  21.         public bool autoShowRecord = false;
  22.         public double autoSearchDays = 2;
  23.         public string lastAutoSearchDate = string.Empty;
  24.         public string reminder = "2";
  25.         public string guideStartTime = "";
  26.         public string schedule = "GBPVR";
  27.         public string recordingQuality = "Medium";
  28.         public bool showTVGuide = true;
  29.         public bool showManage = true;
  30.         public bool showSearch = true;
  31.         public bool showMusicLib = true;
  32.         public bool showVideoLib = true;
  33.         public bool showPhotoLib = true;
  34.         public bool showStats = true;
  35.         public bool showSubtitle = true;
  36.         public bool showDescription = true;
  37.         public string showGenre = "singleGenre";
  38.         public bool showRating = true;
  39.         public bool showNew = true;
  40.         public bool showHD = true;
  41.         public bool showIMDB = true;
  42.         public bool showNetflix = true;
  43.         public bool showTVCom = true;
  44.         public bool showWiki = true;
  45.         public bool showCredits = true;
  46.         public bool showAirDate = true;
  47.         public bool showStarRating = true;
  48.         public string channelIconExtensions = "jpg,png,gif";
  49.         public string playlistExtension = "m3u";
  50.         public string photoFiles = @"^.*\.(gif|jpg|jpeg|bmp|wmf|png)$";
  51.         public string musicFiles = @"^.*\.(mp3|wav|ogg|wma|ape|m4a|mkv)$";
  52.         public string videoFiles = @"^.*\.(mpeg|mpg|m2v|avi|ogm|mp4|wmv|iso|divx|rm|dvr-ms)$";
  53.         public string coverFiles = @"^(~|cover|folder|default|albumart)\.(jpg|gif|png|bmp)$";
  54.         public string autologinNetworks = "127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16";
  55.         public string GuestUser = "";
  56.         public string GuestPassword = "";
  57.         public string CurrentSearchVersion = "2.0";
  58.         
  59.         //VLC Profile 1 Default Settings
  60.         public string strmPlayer = "VLC";
  61.         public bool strmExternal = true;
  62.  
  63.         public string strmVLCLoc = "C:\\Program Files\\VideoLAN\\Vlc\\";
  64.         public int strmPort = 7648;
  65.         public int strmBuffer = 5000;
  66.         public string strmPriority = "BelowNormal";
  67.         public string strmSetting = "0";
  68.         public int strmBitRate = 0;
  69.         public string strmVideoSizeOpt = "preset";
  70.         public string strmVideoSize = "320x213";
  71.         public string strmVideoScaleSize = "01.00";
  72.         
  73.         public string strmMux = "ts";
  74.         public string strmVideo = "mpg4";
  75.         public string strmAudio = "mp4v";
  76.         public string strmAudoBitrate = "32";
  77.         public string strmAudioChannels = "2";
  78.         public string strmVEncoder = "default";
  79.  
  80.         public string strmH264KeyInt = "";
  81.         public string strmH264IDRInt = "";
  82.         public string strmH264BFrames = "";
  83.         public string strmH264QuantizerParam = "";
  84.         public string strmH264QuantizerMax = "";
  85.         public string strmH264QuantizerMin = "";
  86.         public bool strmH264CABAC = true;
  87.         public bool strmH264LoopFilter = true;
  88.         public bool strmH264Analyse = false;
  89.         public string strmH264FrameRef = "";
  90.         public string strmH264Adapt = "none";
  91.         public string strmH264Me = "dia";
  92.         public string strmH264SubME = "1";
  93.         public string strmH264ChromaME = "none";
  94.         public string strmH264MERange = "1";
  95.  
  96.         //VLC Profile 2 Default Settings
  97.         public string strmPlayer2 = "VLC";
  98.         public bool strmExternal2 = true;
  99.  
  100.         public string strmVLCLoc2 = "C:\\Program Files\\VideoLAN\\Vlc\\";
  101.         public int strmPort2 = 7648;
  102.         public int strmBuffer2 = 5000;
  103.         public string strmPriority2 = "BelowNormal";
  104.         public string strmSetting2 = "0";
  105.         public int strmBitRate2 = 0;
  106.         public string strmVideoSizeOpt2 = "preset";
  107.         public string strmVideoSize2 = "320x213";
  108.         public string strmVideoScaleSize2 = "01.00";
  109.  
  110.         public string strmMux2 = "ts";
  111.         public string strmVideo2 = "mpg4";
  112.         public string strmAudio2 = "mp3";
  113.         public string strmAudoBitrate2 = "128";
  114.         public string strmAudioChannels2 = "2";
  115.         public string strmVEncoder2 = "default";
  116.  
  117.         public string strmH264KeyInt2 = "";
  118.         public string strmH264IDRInt2 = "";
  119.         public string strmH264BFrames2 = "";
  120.         public string strmH264QuantizerParam2 = "";
  121.         public string strmH264QuantizerMax2 = "";
  122.         public string strmH264QuantizerMin2 = "";
  123.         public bool strmH264CABAC2 = true;
  124.         public bool strmH264LoopFilter2 = true;
  125.         public bool strmH264Analyse2 = false;
  126.         public string strmH264FrameRef2 = "";
  127.         public string strmH264Adapt2 = "none";
  128.         public string strmH264Me2 = "dia";
  129.         public string strmH264SubME2 = "1";
  130.         public string strmH264ChromaME2 = "none";
  131.         public string strmH264MERange2 = "1";
  132.         
  133.         [NonSerialized()]
  134.         public IPList autologinNets;
  135.  
  136.         public Settings()
  137.         {
  138.             //
  139.             // TODO: Add constructor logic here
  140.             //
  141.             Load();
  142.         }
  143.  
  144.         private void Load()
  145.         {
  146.             string value;
  147.             DateTime tmpDate = DateTime.Now.AddDays(-1);
  148.             lastAutoSearchDate = tmpDate.ToShortDateString();
  149.             value = GetSetting(this, "CurrentSearchVersion"); if ((value != null) && (value.Length > 0)) CurrentSearchVersion = value;
  150.             value = GetSetting(this, "autoShowSearch");     if ((value != null) && (value.Length > 0)) autoShowSearch = Convert.ToBoolean(value);
  151.             value = GetSetting(this, "autoShowRecord");     if ((value != null) && (value.Length > 0)) autoShowRecord = Convert.ToBoolean(value);
  152.             value = GetSetting(this, "autoSearchDays");     if ((value != null) && (value.Length > 0)) autoSearchDays = Convert.ToDouble(value);
  153.             value = GetSetting(this, "lastAutoSearchDate"); if ((value != null) && (value.Length > 0)) lastAutoSearchDate = value;
  154.             value = GetSetting(this, "showTVGuide");        if ((value != null) && (value.Length > 0)) showTVGuide = Convert.ToBoolean(value);
  155.             value = GetSetting(this, "showManage");         if ((value != null) && (value.Length > 0)) showManage = Convert.ToBoolean(value);
  156.             value = GetSetting(this, "showSearch");         if ((value != null) && (value.Length > 0)) showSearch = Convert.ToBoolean(value);
  157.             value = GetSetting(this, "showMusicLib");       if ((value != null) && (value.Length > 0)) showMusicLib = Convert.ToBoolean(value);
  158.             value = GetSetting(this, "showVideoLib");       if ((value != null) && (value.Length > 0)) showVideoLib = Convert.ToBoolean(value);
  159.             value = GetSetting(this, "showPhotoLib");       if ((value != null) && (value.Length > 0)) showPhotoLib = Convert.ToBoolean(value);
  160.             value = GetSetting(this, "showStats");          if ((value != null) && (value.Length > 0)) showStats = Convert.ToBoolean(value);
  161.             value = GetSetting(this, "reminder");           if ((value != null) && (value.Length > 0)) reminder = value;
  162.             value = GetSetting(this, "guideStartTime");     if ((value != null) && (value.Length > 0)) guideStartTime = value;
  163.             value = GetSetting(this, "schedule");            if ((value != null) && (value.Length > 0)) schedule = value;
  164.             value = GetSetting(this, "recordingQuality");    if ((value != null) && (value.Length > 0)) recordingQuality = value;
  165.             value = GetSetting(this, "showDescription");    if ((value != null) && (value.Length > 0)) showDescription = Convert.ToBoolean(value);
  166.             value = GetSetting(this, "showSubtitle");        if ((value != null) && (value.Length > 0)) showSubtitle = Convert.ToBoolean(value);
  167.             value = GetSetting(this, "showGenre");            if ((value != null) && (value.Length > 0)) showGenre = value;
  168.             if (showGenre.ToLower() == "true")                showGenre = "singleGenre";
  169.             if (showGenre.ToLower() == "false")                showGenre = "noGenre";
  170.             value = GetSetting(this, "showRating");            if ((value != null) && (value.Length > 0)) showRating = Convert.ToBoolean(value);
  171.             value = GetSetting(this, "showNew");            if ((value != null) && (value.Length > 0)) showNew = Convert.ToBoolean(value);
  172.             value = GetSetting(this, "showHD");             if ((value != null) && (value.Length > 0)) showHD = Convert.ToBoolean(value);
  173.             value = GetSetting(this, "showIMDB");            if ((value != null) && (value.Length > 0)) showIMDB = Convert.ToBoolean(value);
  174.             value = GetSetting(this, "showNetflix");        if ((value != null) && (value.Length > 0)) showNetflix = Convert.ToBoolean(value);
  175.             value = GetSetting(this, "showTVCom");          if ((value != null) && (value.Length > 0)) showTVCom = Convert.ToBoolean(value);
  176.             value = GetSetting(this, "showWiki");            if ((value != null) && (value.Length > 0)) showWiki = Convert.ToBoolean(value);
  177.             value = GetSetting(this, "showCredits");        if ((value != null) && (value.Length > 0)) showCredits = Convert.ToBoolean(value);
  178.             value = GetSetting(this, "showAirDate");        if ((value != null) && (value.Length > 0)) showAirDate = Convert.ToBoolean(value);
  179.             value = GetSetting(this, "showStarRating");     if ((value != null) && (value.Length > 0)) showStarRating = Convert.ToBoolean(value);
  180.             value = GetSetting(this, "playlistExtnesion");    if ((value != null) && (value.Length > 0)) playlistExtension = value;
  181.             value = GetSetting(this, "autologinNetworks");    if ((value != null) && (value.Length > 0)) autologinNetworks = value;
  182.             value = GetSetting(this, "GuestUser");          if ((value != null) && (value.Length > 0)) GuestUser = value;
  183.             value = GetSetting(this, "GuestPassword");      if ((value != null) && (value.Length > 0)) GuestPassword = value;
  184.  
  185.             value = GetSetting(this, "strmPlayer"); if ((value != null) && (value.Length > 0)) strmPlayer = value;
  186.             value = GetSetting(this, "stremExternal"); if ((value != null) && (value.Length > 0)) strmExternal = Convert.ToBoolean(value);
  187.             value = GetSetting(this, "strmVLCLoc"); if ((value != null) && (value.Length > 0)) strmVLCLoc = value;
  188.             value = GetSetting(this, "strmPort"); if ((value != null) && (value.Length > 0)) strmPort = Convert.ToInt32(value);
  189.             value = GetSetting(this, "strmBuffer"); if ((value != null) && (value.Length > 0)) strmBuffer = Convert.ToInt32(value);
  190.             value = GetSetting(this, "strmPriority"); if ((value != null) && (value.Length > 0)) strmPriority = value;
  191.             value = GetSetting(this, "strmBitRate"); if ((value != null) && (value.Length > 0)) strmBitRate = Convert.ToInt32(value);
  192.             value = GetSetting(this, "strmVideoSizeOpt"); if ((value != null) && (value.Length > 0)) strmVideoSizeOpt = value;
  193.             value = GetSetting(this, "strmVideoSize"); if ((value != null) && (value.Length > 0)) strmVideoSize = value;            
  194.             value = GetSetting(this, "strmVideoScaleSize"); if ((value != null) && (value.Length > 0)) strmVideoScaleSize = value;
  195.             value = GetSetting(this, "strmSetting"); if ((value != null) && (value.Length > 0)) strmSetting = value;
  196.             value = GetSetting(this, "strmMux"); if ((value != null) && (value.Length > 0)) strmMux = value;
  197.             value = GetSetting(this, "strmVideo"); if ((value != null) && (value.Length > 0)) strmVideo = value;
  198.             value = GetSetting(this, "strmAudio"); if ((value != null) && (value.Length > 0)) strmAudio = value;
  199.             value = GetSetting(this, "strmAudoBitrate"); if ((value != null) && (value.Length > 0)) strmAudoBitrate = value;
  200.             value = GetSetting(this, "strmAudioChannels"); if ((value != null) && (value.Length > 0)) strmAudioChannels = value;
  201.             value = GetSetting(this, "strmVEncoder"); if ((value != null) && (value.Length > 0)) strmVEncoder = value;
  202.             value = GetSetting(this, "strmH264KeyInt"); if ((value != null) && (value.Length > 0)) strmH264KeyInt = value;
  203.             value = GetSetting(this, "strmH264IDRInt"); if ((value != null) && (value.Length > 0)) strmH264IDRInt = value;
  204.             value = GetSetting(this, "strmH264BFrames"); if ((value != null) && (value.Length > 0)) strmH264BFrames = value;
  205.             value = GetSetting(this, "strmH264QuantizerParam"); if ((value != null) && (value.Length > 0)) strmH264QuantizerParam = value;
  206.             value = GetSetting(this, "strmH264QuantizerMax"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMax = value;
  207.             value = GetSetting(this, "strmH264QuantizerMin"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMin = value;
  208.             value = GetSetting(this, "strmH264CABAC"); if ((value != null) && (value.Length > 0)) strmH264CABAC = Convert.ToBoolean(value);
  209.             value = GetSetting(this, "strmH264LoopFilter"); if ((value != null) && (value.Length > 0)) strmH264LoopFilter = Convert.ToBoolean(value);
  210.             value = GetSetting(this, "strmH264Analyse"); if ((value != null) && (value.Length > 0)) strmH264Analyse = Convert.ToBoolean(value);
  211.             value = GetSetting(this, "strmH264FrameRef"); if ((value != null) && (value.Length > 0)) strmH264FrameRef = value;
  212.             value = GetSetting(this, "strmH264Adapt"); if ((value != null) && (value.Length > 0)) strmH264Adapt = value;
  213.             value = GetSetting(this, "strmH264Me"); if ((value != null) && (value.Length > 0)) strmH264Me = value;
  214.             value = GetSetting(this, "strmH264SubME"); if ((value != null) && (value.Length > 0)) strmH264SubME = value;
  215.             value = GetSetting(this, "strmH264ChromaME"); if ((value != null) && (value.Length > 0)) strmH264ChromaME = value;
  216.             value = GetSetting(this, "strmH264MERange"); if ((value != null) && (value.Length > 0)) strmH264MERange = value;
  217.  
  218.             value = GetSetting(this, "strmPlayer2"); if ((value != null) && (value.Length > 0)) strmPlayer2 = value;
  219.             value = GetSetting(this, "stremExternal2"); if ((value != null) && (value.Length > 0)) strmExternal2 = Convert.ToBoolean(value);
  220.             value = GetSetting(this, "strmVLCLoc2"); if ((value != null) && (value.Length > 0)) strmVLCLoc2 = value;
  221.             value = GetSetting(this, "strmPort2"); if ((value != null) && (value.Length > 0)) strmPort2 = Convert.ToInt32(value);
  222.             value = GetSetting(this, "strmBuffer2"); if ((value != null) && (value.Length > 0)) strmBuffer2 = Convert.ToInt32(value);
  223.             value = GetSetting(this, "strmPriority2"); if ((value != null) && (value.Length > 0)) strmPriority2 = value;
  224.             value = GetSetting(this, "strmBitRate2"); if ((value != null) && (value.Length > 0)) strmBitRate2 = Convert.ToInt32(value);
  225.             value = GetSetting(this, "strmVideoSizeOpt2"); if ((value != null) && (value.Length > 0)) strmVideoSizeOpt2 = value;
  226.             value = GetSetting(this, "strmVideoSize2"); if ((value != null) && (value.Length > 0)) strmVideoSize2 = value;
  227.             value = GetSetting(this, "strmVideoScaleSize2"); if ((value != null) && (value.Length > 0)) strmVideoScaleSize2 = value;
  228.             value = GetSetting(this, "strmSetting2"); if ((value != null) && (value.Length > 0)) strmSetting2 = value;
  229.             value = GetSetting(this, "strmMux2"); if ((value != null) && (value.Length > 0)) strmMux2 = value;
  230.             value = GetSetting(this, "strmVideo2"); if ((value != null) && (value.Length > 0)) strmVideo2 = value;
  231.             value = GetSetting(this, "strmAudio2"); if ((value != null) && (value.Length > 0)) strmAudio2 = value;
  232.             value = GetSetting(this, "strmAudoBitrate2"); if ((value != null) && (value.Length > 0)) strmAudoBitrate2 = value;
  233.             value = GetSetting(this, "strmAudioChannels2"); if ((value != null) && (value.Length > 0)) strmAudioChannels2 = value;
  234.             value = GetSetting(this, "strmVEncoder2"); if ((value != null) && (value.Length > 0)) strmVEncoder2 = value;
  235.             value = GetSetting(this, "strmH264KeyInt2"); if ((value != null) && (value.Length > 0)) strmH264KeyInt2 = value;
  236.             value = GetSetting(this, "strmH264IDRInt2"); if ((value != null) && (value.Length > 0)) strmH264IDRInt2 = value;
  237.             value = GetSetting(this, "strmH264BFrames2"); if ((value != null) && (value.Length > 0)) strmH264BFrames2 = value;
  238.             value = GetSetting(this, "strmH264QuantizerParam2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerParam2 = value;
  239.             value = GetSetting(this, "strmH264QuantizerMax2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMax2 = value;
  240.             value = GetSetting(this, "strmH264QuantizerMin2"); if ((value != null) && (value.Length > 0)) strmH264QuantizerMin2 = value;
  241.             value = GetSetting(this, "strmH264CABAC2"); if ((value != null) && (value.Length > 0)) strmH264CABAC2 = Convert.ToBoolean(value);
  242.             value = GetSetting(this, "strmH264LoopFilter2"); if ((value != null) && (value.Length > 0)) strmH264LoopFilter2 = Convert.ToBoolean(value);
  243.             value = GetSetting(this, "strmH264Analyse2"); if ((value != null) && (value.Length > 0)) strmH264Analyse2 = Convert.ToBoolean(value);
  244.             value = GetSetting(this, "strmH264FrameRef2"); if ((value != null) && (value.Length > 0)) strmH264FrameRef2 = value;
  245.             value = GetSetting(this, "strmH264Adapt2"); if ((value != null) && (value.Length > 0)) strmH264Adapt2 = value;
  246.             value = GetSetting(this, "strmH264Me2"); if ((value != null) && (value.Length > 0)) strmH264Me2 = value;
  247.             value = GetSetting(this, "strmH264SubME2"); if ((value != null) && (value.Length > 0)) strmH264SubME2 = value;
  248.             value = GetSetting(this, "strmH264ChromaME2"); if ((value != null) && (value.Length > 0)) strmH264ChromaME2 = value;
  249.             value = GetSetting(this, "strmH264MERange2"); if ((value != null) && (value.Length > 0)) strmH264MERange2 = value;
  250.  
  251.             string[] invalidAutologinNetworks = ParseAutologinNetworks();
  252.             if (invalidAutologinNetworks.Length > 0)
  253.             {
  254.                 Logger.Warning("Invalid autologinNetworks: " + string.Join(",", invalidAutologinNetworks));
  255.             }
  256.         }
  257.  
  258.         public void Save()
  259.         {
  260.             SetSetting(this, "CurrentSearchVersion", CurrentSearchVersion);
  261.             SetSetting(this, "autoShowSearch", autoShowSearch.ToString());
  262.             SetSetting(this, "autoShowRecord", autoShowRecord.ToString());
  263.             SetSetting(this, "autoSearchDays", autoSearchDays.ToString());
  264.             SetSetting(this, "lastAutoSearchDate", lastAutoSearchDate);
  265.             SetSetting(this, "showTVGuide", showTVGuide.ToString());
  266.             SetSetting(this, "showManage", showManage.ToString());
  267.             SetSetting(this, "showSearch", showSearch.ToString());
  268.             SetSetting(this, "showMusicLib", showMusicLib.ToString());
  269.             SetSetting(this, "showVideoLib", showVideoLib.ToString());
  270.             SetSetting(this, "showPhotoLib", showPhotoLib.ToString());
  271.             SetSetting(this, "showStats", showStats.ToString());
  272.             SetSetting(this, "reminder"             , reminder);
  273.             SetSetting(this, "guideStartTime"       , guideStartTime);
  274.             SetSetting(this, "schedule"                , schedule);
  275.             SetSetting(this, "recordingQuality"        , recordingQuality);
  276.             SetSetting(this, "showDescription"        , showDescription.ToString());
  277.             SetSetting(this, "showSubtitle"            , showSubtitle.ToString());
  278.             SetSetting(this, "showGenre"            , showGenre);
  279.             SetSetting(this, "showRating"            , showRating.ToString());
  280.             SetSetting(this, "showNew"                , showNew.ToString());
  281.             SetSetting(this, "showHD"               , showHD.ToString());
  282.             SetSetting(this, "showIMDB"                , showIMDB.ToString());
  283.             SetSetting(this, "showNetflix"            , showNetflix.ToString());
  284.             SetSetting(this, "showTVCom"            , showTVCom.ToString());
  285.             SetSetting(this, "showWiki"                , showWiki.ToString());
  286.             SetSetting(this, "showCredits"            , showCredits.ToString());
  287.             SetSetting(this, "showAirDate"            , showAirDate.ToString());
  288.             SetSetting(this, "showStarRating"        , showStarRating.ToString());
  289.             SetSetting(this, "playlistExtnesion"    , playlistExtension);
  290.             SetSetting(this, "autologinNetworks"    , autologinNetworks);
  291.             SetSetting(this, "GuestUser"            , GuestUser);
  292.             SetSetting(this, "GuestPassword"        , GuestPassword);
  293.  
  294.             SetSetting(this, "strmPlayer", strmPlayer);
  295.             SetSetting(this, "strmExternal", strmExternal.ToString());
  296.             SetSetting(this, "strmVLCLoc", strmVLCLoc);
  297.             SetSetting(this, "strmPort", strmPort.ToString());
  298.             SetSetting(this, "strmBuffer", strmBuffer.ToString());
  299.             SetSetting(this, "strmPriority", strmPriority);
  300.             SetSetting(this, "strmBitRate", strmBitRate.ToString());
  301.             SetSetting(this, "strmVideoSizeOpt", strmVideoSizeOpt);
  302.             SetSetting(this, "strmVideoSize", strmVideoSize);
  303.             SetSetting(this, "strmVideoScaleSize", strmVideoScaleSize);
  304.             SetSetting(this, "strmSetting", strmSetting);
  305.             SetSetting(this, "strmMux", strmMux);
  306.             SetSetting(this, "strmVideo", strmVideo);
  307.             SetSetting(this, "strmAudio", strmAudio);
  308.             SetSetting(this, "strmAudoBitrate", strmAudoBitrate);
  309.             SetSetting(this, "strmAudioChannels", strmAudioChannels);
  310.             SetSetting(this, "strmVEncoder", strmVEncoder);
  311.             
  312.             SetSetting(this, "strmH264KeyInt", strmH264KeyInt);
  313.             SetSetting(this, "strmH264IDRInt", strmH264IDRInt);
  314.             SetSetting(this, "strmH264BFrames", strmH264BFrames);
  315.             SetSetting(this, "strmH264QuantizerParam", strmH264QuantizerParam);
  316.             SetSetting(this, "strmH264QuantizerMax", strmH264QuantizerMax);
  317.             SetSetting(this, "strmH264QuantizerMin", strmH264QuantizerMin);
  318.             SetSetting(this, "strmH264CABAC", strmH264CABAC.ToString());
  319.             SetSetting(this, "strmH264LoopFilter", strmH264LoopFilter.ToString());
  320.             SetSetting(this, "strmH264Analyse", strmH264Analyse.ToString());
  321.             SetSetting(this, "strmH264FrameRef", strmH264FrameRef);
  322.             SetSetting(this, "strmH264Adapt", strmH264Adapt);
  323.             SetSetting(this, "strmH264Me", strmH264Me);
  324.             SetSetting(this, "strmH264SubME", strmH264SubME);
  325.             SetSetting(this, "strmH264ChromaME", strmH264ChromaME);
  326.             SetSetting(this, "strmH264MERange", strmH264MERange);
  327.  
  328.             SetSetting(this, "strmPlayer2", strmPlayer2);
  329.             SetSetting(this, "strmExternal2", strmExternal2.ToString());
  330.             SetSetting(this, "strmVLCLoc2", strmVLCLoc2);
  331.             SetSetting(this, "strmPort2", strmPort2.ToString());
  332.             SetSetting(this, "strmBuffer2", strmBuffer2.ToString());
  333.             SetSetting(this, "strmPriority2", strmPriority2);
  334.             SetSetting(this, "strmBitRate2", strmBitRate2.ToString());
  335.             SetSetting(this, "strmVideoSizeOpt2", strmVideoSizeOpt2);
  336.             SetSetting(this, "strmVideoSize2", strmVideoSize2);
  337.             SetSetting(this, "strmVideoScaleSize2", strmVideoScaleSize2);
  338.             SetSetting(this, "strmSetting2", strmSetting2);
  339.             SetSetting(this, "strmMux2", strmMux2);
  340.             SetSetting(this, "strmVideo2", strmVideo2);
  341.             SetSetting(this, "strmAudio2", strmAudio2);
  342.             SetSetting(this, "strmAudoBitrate2", strmAudoBitrate2);
  343.             SetSetting(this, "strmAudioChannels2", strmAudioChannels2);
  344.             SetSetting(this, "strmVEncoder2", strmVEncoder2);
  345.  
  346.             SetSetting(this, "strmH264KeyInt2", strmH264KeyInt2);
  347.             SetSetting(this, "strmH264IDRInt2", strmH264IDRInt2);
  348.             SetSetting(this, "strmH264BFrames2", strmH264BFrames2);
  349.             SetSetting(this, "strmH264QuantizerParam2", strmH264QuantizerParam2);
  350.             SetSetting(this, "strmH264QuantizerMax2", strmH264QuantizerMax2);
  351.             SetSetting(this, "strmH264QuantizerMin2", strmH264QuantizerMin2);
  352.             SetSetting(this, "strmH264CABAC2", strmH264CABAC2.ToString());
  353.             SetSetting(this, "strmH264LoopFilter2", strmH264LoopFilter2.ToString());
  354.             SetSetting(this, "strmH264Analyse2", strmH264Analyse2.ToString());
  355.             SetSetting(this, "strmH264FrameRef2", strmH264FrameRef2);
  356.             SetSetting(this, "strmH264Adapt2", strmH264Adapt2);
  357.             SetSetting(this, "strmH264Me2", strmH264Me2);
  358.             SetSetting(this, "strmH264SubME2", strmH264SubME2);
  359.             SetSetting(this, "strmH264ChromaME2", strmH264ChromaME2);
  360.             SetSetting(this, "strmH264MERange2", strmH264MERange2);
  361.  
  362.             SaveToFile();
  363.         }
  364.  
  365.         public string[] ParseAutologinNetworks()
  366.         {
  367.             ArrayList invalidAutologinNetworks = new ArrayList();
  368.             autologinNets = new IPList();
  369.             if (autologinNetworks.Length > 0)
  370.             {
  371.                 foreach (string autologinNetwork in autologinNetworks.Split(','))
  372.                 {
  373.                     if (autologinNetwork.ToLower() == "none") continue;
  374.                     try 
  375.                     {
  376.                         string[] networkDetails = autologinNetwork.Split('/');
  377.                         if (networkDetails.Length == 1)
  378.                         {
  379.                             autologinNets.Add(networkDetails[0]);
  380.                         }
  381.                         else if (networkDetails.Length == 2)
  382.                         {
  383.                             int parts = networkDetails[1].Split('.').Length;
  384.                             if (parts == 1)
  385.                             {
  386.                                 autologinNets.Add(networkDetails[0], Convert.ToInt32(networkDetails[1]));
  387.                             }
  388.                             else if (parts == 4)
  389.                             {
  390.                                 autologinNets.Add(networkDetails[0], networkDetails[1]);
  391.                             }
  392.                             else
  393.                             {
  394.                                 invalidAutologinNetworks.Add(autologinNetwork);
  395.                             }
  396.                         }
  397.                         else
  398.                         {
  399.                             invalidAutologinNetworks.Add(autologinNetwork);
  400.                         }
  401.                     }
  402.                     catch
  403.                     {
  404.                         invalidAutologinNetworks.Add(autologinNetwork);
  405.                     }
  406.                 }
  407.             }
  408.             return (string[])invalidAutologinNetworks.ToArray(typeof(string));
  409.         }
  410.  
  411.         private static string versionToolTip;
  412.         public string GetVersionToolTip()
  413.         {
  414.             if (versionToolTip == null)
  415.             {
  416.                 Assembly me = Assembly.GetExecutingAssembly();
  417.                 string configuration = ((AssemblyConfigurationAttribute)me.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)[0]).Configuration;
  418.                 string version = me.GetName().Version.ToString(2);
  419.                 XmlDocument changeLog = new XmlDocument();
  420.                 changeLog.Load(HttpContext.Current.Server.MapPath("~/public/ChangeLog.xml"));
  421.                 string[] revision = changeLog.SelectSingleNode("/changelog/@commit_revision").Value.Split(new char[] {' ', '$'});
  422.                 versionToolTip = "GB-PVR web server, " + configuration + ", version: " + version + "." + revision[2];
  423.             }
  424.             return versionToolTip;
  425.         }
  426.  
  427.         #region Private Variables
  428.  
  429.         private HybridDictionary globalSettings;
  430.         private string webConfigFileName;
  431.         private XmlDocument configWeb;
  432.  
  433.         #endregion
  434.  
  435.         #region Public Global Settings Methods
  436.  
  437.         public string GetSetting(object moduleObject, string settingName)
  438.         {
  439.             string moduleName = "gbweb";
  440.  
  441.             //Logger.Verbose("RecorderHelperConfig: GetSetting(" + moduleName + ", " + settingName + ")");
  442.  
  443.             LoadFromFile(false);
  444.  
  445.             XmlNode globalSettingsNode = (XmlNode)globalSettings[moduleName];
  446.  
  447.             if (globalSettingsNode == null) return null;
  448.  
  449.             XmlNode settingNode = globalSettingsNode.SelectSingleNode(settingName);
  450.  
  451.             if (settingNode == null) return null;
  452.  
  453.             return settingNode.InnerText;
  454.         }
  455.  
  456.         public void SetSetting(object moduleObject, string settingName, string value)
  457.         {
  458.             string moduleName = "gbweb";
  459.  
  460.             //Logger.Verbose("RecorderHelperConfig: SetSetting(" + moduleName + ", " + settingName + ")");
  461.  
  462.             XmlNode globalSettingsNode = (XmlNode)globalSettings[moduleName];
  463.  
  464.             if (globalSettingsNode == null)
  465.             {
  466.                 globalSettingsNode = configWeb.CreateElement(moduleName);
  467.                 globalSettings[moduleName] = globalSettingsNode;
  468.             }
  469.  
  470.             XmlNode settingNode = globalSettingsNode.SelectSingleNode(settingName);
  471.  
  472.             if (settingNode == null)
  473.             {
  474.                 settingNode = configWeb.CreateElement(settingName);
  475.                 globalSettingsNode.AppendChild(settingNode);
  476.             }
  477.  
  478.             settingNode.InnerText = value;
  479.         }
  480.  
  481.         public void SaveSettings()
  482.         {
  483.             SaveToFile();
  484.         }
  485.  
  486.         #endregion
  487.  
  488.         #region Private Methods
  489.  
  490.         private void LoadFromFile(bool reload)
  491.         {
  492.             if (!reload && (configWeb != null)) return;
  493.  
  494.             Logger.Verbose("RecorderHelperConfig: LoadFromFile()");
  495.  
  496.             configWeb = new XmlDocument();
  497.  
  498.             if (File.Exists(GetWebConfigFileName()))
  499.                 configWeb.Load(GetWebConfigFileName());
  500.  
  501.             globalSettings = new HybridDictionary();
  502.  
  503.             foreach (XmlNode globalSettingsNode in configWeb.SelectNodes("settings/globalSettings/*"))
  504.             {
  505.                 globalSettings[globalSettingsNode.Name] = globalSettingsNode;
  506.             }
  507.  
  508.         }
  509.  
  510.         private void SaveToFile()
  511.         {
  512.             Logger.Verbose("RecorderHelperConfig: SaveToFile()");
  513.  
  514.             configWeb.RemoveAll();
  515.  
  516.             configWeb.AppendChild(configWeb.CreateXmlDeclaration("1.0", "UTF-8", null));
  517.  
  518.             XmlNode settings = configWeb.CreateElement("settings");
  519.             configWeb.AppendChild(settings);
  520.  
  521.             XmlNode global = configWeb.CreateElement("globalSettings");
  522.             settings.AppendChild(global);
  523.  
  524.             ArrayList globalSettingsKeys = new ArrayList(globalSettings.Keys);
  525.             globalSettingsKeys.Sort();
  526.             foreach (string globalSettingKey in globalSettingsKeys)
  527.             {
  528.                 global.AppendChild((XmlNode)globalSettings[globalSettingKey]);
  529.             }
  530.  
  531.             configWeb.Save(GetWebConfigFileName());
  532.         }
  533.  
  534.         private string GetWebConfigFileName()
  535.         {
  536.             if (webConfigFileName == null)
  537.             {
  538.                 webConfigFileName = Path.Combine(GetInstallDir(), "config-web.xml");
  539.             }
  540.             return webConfigFileName;
  541.         }
  542.  
  543.         public string GetInstallDir()
  544.         {
  545.             // determine install location
  546.             string installDirectory = @"c:\program files\devnz\gbpvr\";
  547.             try
  548.             {
  549.                 using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\devnz\"))
  550.                 {
  551.                     string temp = (string)key.GetValue("GBPVR InstallDir");
  552.                     if (temp != null)
  553.                     {
  554.                         installDirectory = temp;
  555.                     }
  556.                 }
  557.             }
  558.             catch (Exception ex)
  559.             {
  560.                 Logger.Error("Error reading install location from registry: " + ex.ToString());
  561.             }
  562.             return installDirectory;
  563.         }
  564.  
  565.         #endregion
  566.  
  567.     }
  568. }
  569.